package com.github.llyb120.undertaker;

import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.Method;
import java.util.Map;

public class ApiScanner {


    public void scan(ApplicationContext context){
        Map<String, Object> beans = context.getBeansWithAnnotation(RequestMapping.class);
        scan(beans);
    }

    void scan(Map<String, Object> beans){
        beans.entrySet()
                .parallelStream()
                .forEach((entry) -> {
                    analyze(entry.getKey(), entry.getValue());
                });
    }

    void analyze(String beanName, Object bean){
        for (Method method : bean.getClass().getDeclaredMethods()) {
            //是否同样有requestmapping
            RequestMapping mapping = method.getAnnotation(RequestMapping.class);
            if (mapping == null) {
                continue;
            }


        }
    }



}
